package Test.interrupt;

import com.sun.org.slf4j.internal.Logger;
import com.sun.org.slf4j.internal.LoggerFactory;

/**
 * @author pengshuai
 * @date 2022/3/20 22:41
 */
public class InterruptDemo {

    public static final Logger log = LoggerFactory.getLogger(InterruptDemo.class);


    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(() -> {
            log.warn("2222222");
            try {
                log.warn("执行开始");
                //sleep处理中断的方法就是  抛出中断异常   并且会抹去中断标记
                //如果捕获了中断异常，并且需要传递中断，那么就需要   重新设置中断的标记位
                Thread.sleep(7000);
                log.warn("执行结束");
            } catch (InterruptedException e) {
                log.warn("11111111", e);
                log.warn("线程中断标记:" + Thread.currentThread().isInterrupted());
            }
            log.warn("3333333");
        });
        thread.start();

        Thread.sleep(500);


        thread.interrupt();


    }

}
